<template>
  <div class="wrap">
    <button @click="fnLogin">登录</button>
  </div>
</template>

<script>
import { getData, postData } from "@/request/http";
import axios from 'axios'
export default {
  name: "wrap",
  data() {
    return {};
  },
  components: {},
  computed: {},
  mounted() {
    // this.basic()
    // this.port() 
  },
  methods: {
      /* login */
      fnLogin(){
        var data = {
            DataCode: 100,
            name: 'admin',
            passwd: '21232f297a57a5a743894a0e4a801fc3',
        }
        const params = new URLSearchParams();
        for(let key in data){
            params.append(key, data[key]);
        }
        axios.post('/cgi_bin/log_in_out.cgi?timestamp=1652925991927', params, {
            haeders:{
                 "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            }
        }).then(res => {
            console.log(res)
        }).catch(err => {
            console.log(err)
        })
      },
      //
      basic(){
           getData("/cgi_bin/basic.cgi", {
                timestamp: new Date().getTime(),
                })
                .then((res) => {
                    console.log(res);
                })
                .catch((err) => {
                    console.log(err);
            });
      },
      //
      port(){
         var data = {
            DataCode: 999
        }
        const params = new URLSearchParams();
        for(let key in data){
            params.append(key, data[key]);
        }
        axios.post('/cgi_bin/port.cgi?timestamp=1652925991927', params, {
            haeders:{
                 "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            }
        }).then(res => {
            console.log(res)
        }).catch(err => {
            console.log(err)
        }) 
      }
  },
};
</script
<style scoped></style>
